<%= error_messages_for 'shim' %>
<fieldset>          

  <legend><%=h @shim.name %>: <i><%=h @shim.shim_type %></i></legend>
  
  <span style="float:right;">  
    <%= link_to 'Upload A New shim', new_shim_path %> | 
    <% if logged_in? %>
      <% if is_admin? or @shim.user_id==current_user.id %>
        <%= link_to 'Edit Shim', edit_shim_path(@shim) %> | 
      <% end %>
    <% end %> 
    <%= link_to 'View All Shims', shims_path %>
  </span><br />
    
  <div id = "shiminfo" class = "shiminfo_container"> <!--OVERVIEW START-->
    <h3>Overview</h3>
    <%= render :partial => 'annotations/tags', :locals => {:annotatable => @shim}  %>
    
    <div style = "width: 78%; border-right: 1px dotted grey; min-height: 40px;">
      <% if @shim.is_service? %>
        <strong>Service details</strong><br />
        <div id = "shim_content_info">
          <% if @shim_service %>
            <% url = @shim_service.endpoint_url %>
            <% name = @shim_service.name %>
            <% bio_cat = @shim_service.biocat_link.blank? ? nil : 
                @shim_service.biocat_link %>
          <% else %>
            <% url = "ERROR PARSING ENDPOINT" %>
            <% name = @shim.name %>
            <% bio_cat = nil %>
          <% end %>
          <strong>Name: </strong><%= h name %><br />
          <strong><%= @shim.shim_type =~ /wsdl/i ? 
              "WSDL Location":"Endpoint" %>: </strong>
          <%= url=~/error/i ? url : (link_to h(url), url, 
              :target => "blank") %><br />
          <% if bio_cat %>
            <strong>BioCatalogue entry:</strong>
            <%=  link_to bio_cat, bio_cat, :target => "blank" %>
          <% end %>
        </div><br />
      <% else %>
        <h4>
          Beanshell Script
          <span style="float:right;">
            <%= link_to "Download", :action => 'download', :id => @shim.id %>
          </span>
        </h4>
        <div id = "shim_content_info">
          <% shim_data = @shim.shim_blob.data.split("\n") %>
          <% threshold = 9 %>
          <% lines_to_show = (shim_data.size > threshold ? threshold:shim_data.size) %>
          <% lines_to_show.times do |index| %>
            <%=h shim_data[index] %><br/>
          <% end %>
          <i><strong><%= "<br/>...lines of code that have been omitted => #{shim_data.size-threshold} " if shim_data.size > threshold %></strong></i>
        </div>
      
        <h4>Download</h4>
        <div id = "shim_content_info">
          <%= link_to h(@shim.filename), :action => 'download', :id => @shim.id %><br />
        </div>
      <% end %>
      
      <%= render :partial => 'annotations/annotation_box', :locals => {
          :annotatable => @shim, :attribute_name => "category"}  %>
      <%= render :partial => 'annotations/annotation_box', :locals => {
          :annotatable => @shim, :attribute_name => "description"}  %>
      <%= render :partial => 'annotations/annotation_box', :locals => {
          :annotatable => @shim, :attribute_name => "example_workflow"}  %>
    </div>
  </div> <!--OVERVIEW END-->
    
  <hr />
    
  <div class = "shimio_container" id = "shimi_container"> <!--INPUTS START-->
    <span style="float:right;">
      <%= link_to 'Add new input', new_shim_shim_input_url(@shim) %>
    </span>
    <h3>Inputs (<%= @shim.shim_inputs.count -%>)</h3>
    <% unless @shim.shim_inputs.empty? %>
      <%= render :partial => "/shims/shim_io", :collection => @shim.shim_inputs %>
    <% end %>
  </div> <!--IN ENDS-->
    
  <hr />

  <div class = "shimio_container" id = "shimo_container"> <!--OUTPUTS START-->
    <span style="float:right;">
      <%= link_to 'Add new output', new_shim_shim_output_url(@shim) %>
    </span>
    <h3>Outputs (<%= @shim.shim_outputs.count -%>)</h3>
     <% unless @shim.shim_outputs.empty? %>
      <%= render :partial => "/shims/shim_io", :collection => @shim.shim_outputs %> 
    <% end %>
  </div><!--OUT ENDS-->
  
</fieldset>